<?php
require_once('lanceur_spip.php');

include_spip('functions/pdk_common');
//require_once(_DIR_PLUGIN_PDK.'classes/models/PdkArticleModel.php');
require_once(_DIR_PLUGIN_PDK.'classes/simpletest/class.PdkModelTest.php');

class TestClassPdkArticleModel extends PdkModelTest {
    /**
     * PdkRubriqueModel
     */
    private $rubrique_mdl;
    
    public function __construct(){
        parent::__construct();        
        $this->SetPdkModel('PdkArticleModel', pdk_load_class('PdkArticleModel', 'classes/models'));
        
        $this->rubrique_mdl = pdk_load_class('PdkRubriqueModel','classes/models');
        $pdk_models['PdkRubriqueModel'] = $this->rubrique_mdl;
        
        $this->AddPdkModels($pdk_models);
    }
    
    /**
     *  Run before each test
     */
    function setUp() {
        parent::setUp();        
    }
    
    /**
     *  Run after each test
     */
    function tearDown() {
        parent::tearDown();
    }
    
    function __destruct() {
        // Call parent destructor to delete created tables
        parent::__destruct();
    }
    
    /**
     *  When there is no id_secteur in data array, it must be added automatically
     */
    function TestInsertWithoutIDSecteur() {
        $data = array('id_rubrique'=>1);
        $id_article = $this->model->insert($data);
        $selected_data = $this->model->select_by_id($id_article);
        $this->assertEqual(1, $selected_data['id_secteur']);
    }
}
